<style>
/* footer */
.f-link-info {
	position: absolute;
	bottom: 16px;
	right: 20px;
	font-weight: bold;
    text-align: center;
    font-size: 11px;
}
.f-link-info > a {
    color: #fff;
    display: block;
    padding: 8px 2px 6px;
    background-color: #5080D8;
    margin-right: 6px;
    float: left;
    height: 16px;
    width: 130px;
}
.f-link-info > a:hover {
    background-color: #0049BA;
}
#policy, 
#cooperation,
#introduction {
	display: none;
}
</style>
<link href="<?php echo base_url('theme/css/frontend/account-manager.css'); ?>" rel="stylesheet">
<script src="<?php echo base_url('theme/third_party/epicEditor/scripts/epiceditor.js'); ?>" type="text/javascript"></script>
<link rel="stylesheet" href="<?php echo base_url('theme/css/frontend/jquery.Jcrop.min.css'); ?>" type="text/css" />
<div class="management-container booth-container" style="margin-top: 40px;">
  <?php echo validation_errors('<div class="alert alert-error">','</div>'); ?>
  <h3>Đăng ký thông tin gian hàng</h3>
  <hr class="hr" />  
     
  <div class="management-wrapper">
    <h5>Thông tin gian hàng</h5>
    <hr class="hr" />
    <div class="management-block">
  	  <div style="position: relative;">
        <div id="banner_large_append">
          <?php if ($booth['banner_large']): ?>
            <img src="<?php echo base_url('upload/booth/'. $_SESSION['userLoggedIn']['id'] . '/banner_large/' . $booth['banner_large']); ?>" />
          <?php else: ?>
            <img src="<?php echo base_url('theme/images/sample/booth/958x376.jpg'); ?>" />
          <?php endif; ?>
        </div>
        <form method="post" id="banner_large_form" action=<?php echo base_url('booth/ajaxUploadFile/banner_large/'.$booth['id']); ?> enctype=multipart/form-data > 
          <div class="file-upload-wrapper">
          	<input class="file-upload" type="file" id="banner_large" name="banner_large" />Thay đổi ảnh bìa</div>
          <button type="submit" class="submit_btn">Upload Files</button>
        </form>
      </div>
      
      <div style="position: absolute; top: 270px; left: 82px;">
        <div id="logo_append">
          <?php if ($booth['logo']): ?>
            <img src="<?php echo base_url('upload/booth/'. $_SESSION['userLoggedIn']['id'] . '/logo/' . $booth['logo']); ?>" />
          <?php else: ?>
            <img src="<?php echo base_url('theme/images/sample/booth/100x110.jpg'); ?>" />
          <?php endif; ?>
        </div>
        <form method="post" id="logo_form" action=<?php echo base_url('booth/ajaxUploadFile/logo/'.$booth['id']); ?> enctype=multipart/form-data > 
          <div class="logo-file-upload-wrapper">
          	<input class="file-upload" type="file" id="logo" name="logo" />Logo</div>
          <button type="submit" class="submit_btn">Upload Files</button>
        </form>
      </div>
      
      <div style="position: absolute; top: 476px; left: 18px;">
        <div id="avatar_append">
          <?php if ($booth['avatar']): ?>
            <img src="<?php echo base_url('upload/booth/'. $_SESSION['userLoggedIn']['id'] . '/avatar/' . $booth['avatar']); ?>" />
          <?php else: ?>
            <img src="<?php echo base_url('theme/images/sample/booth/224x155.jpg'); ?>" />
          <?php endif; ?>
        </div>
        <form method="post" id="avatar_form" action=<?php echo base_url('booth/ajaxUploadFile/avatar/'.$booth['id']); ?> enctype=multipart/form-data > 
          <div class="avatar-file-upload-wrapper">
          	<input class="file-upload" type="file" id="avatar" name="avatar" />Ảnh đại diện gian hàng</div>
          <button type="submit" class="submit_btn">Upload Files</button>
        </form>
      </div>
  
      <form method="post" id="ad-form" class="form-horizontal" action=<?php echo base_url('booth/add'); ?>>
        <div class="control-group">
          <label for="category_select" class="control-label">Chuyên mục<i>*</i></label>
          <div class="controls">
         	<a href="<?php echo base_url('booth/categories?ajax=true'); ?>" rel=categoryPopup[ajax] >
              <input type=text id=category_select class="input-xxlarge" value="<?php echo set_value('category_id', getBoothCategories($booth['category_id'])); ?>">	
              <input type=hidden name=category_id id=category_id value="<?php echo set_value('category_id', $booth['category_id']); ?>">             	
              <input type="hidden" name=slug id="slug" value="<?php echo set_value('slug', $booth['slug']); ?>"/>
            </a>
            <script type="text/javascript">
            $(document).ready(function(){              
              // Category popup
              $("a[rel^='categoryPopup']").prettyPhoto({
                ajaxcallback: function() {
                  $(".category-list > ul > li > a").click(function(){
                    var category_id = $(this).data('category'); 
                    $('#category_select').val($(this).text()); 
                    $('#category_id').val(category_id);  	
          
                    $('#slug').val($(this).html());
                                  
                    $.prettyPhoto.close();
                	  return false;
                  });
          
                  $(".category-list > ul > li > ul > li > a").click(function(){
          	          var category_id = $(this).data('category'); 
                      $('#category_select').val($(this).text()); 
                      $('#category_id').val(category_id);  	 
          
                      var root = $(this).parent().parent().prev().html() + '/';
                      $('#slug').val(root + $(this).html());
                                   
                      $.prettyPhoto.close();
                  	  return false;
                    }); 
                },
                markup: '<div class="pp_container" role="dialog"><div class="pp_loaderIcon"></div><div class="pp_placeholder"></div></div><div class="pp_overlay"></div>'
              });
            });
            </script>
          </div>
        </div>
        <div class="control-group">
          <label for="name" class="control-label">Tên gian hàng<i>*</i></label>
          <div class="controls">
            <input type=text name=name id=name class="input-xxlarge" value="<?php echo set_value('name', $booth['name']); ?>">
           </div>
        </div>
        <div class="control-group">
          <label for="address" class="control-label">Địa chỉ<i>*</i></label>
          <div class="controls">
            <input type=text name=address id=address class="input-xxlarge" value="<?php echo set_value('address', $booth['address']); ?>">
         	</div>
        </div>
        <div class="control-group">
           <label for="posting_area" class="control-label">Khu vực đăng tin<i>*</i></label>
           <div class="controls">
         	  <a href="<?php echo base_url('city/index?ajax=true'); ?>" rel=postAreaPopup[ajax]>
              <input type=text id=posting_area_select class="input-xxlarge" value="<?php echo set_value('posting_area', getCity(@$booth['posting_area'])); ?>">	
              <input type=hidden name=posting_area id=posting_area value="<?php echo set_value('posting_area', @$booth['posting_area']); ?>">             	
              </a>
              <script type="text/javascript">
              $(document).ready(function(){
                // City popup
                $("a[rel^='postAreaPopup']").prettyPhoto({
                  type: 'city',
                  ajaxcallback: function() {
                	// city popup
      	            $(".city-list ul li a, .city-list h4 a").click(function(){ 
      	              $('#posting_area_select').val($(this).text()); 
      	              $('#posting_area').val($(this).data('city'));
      	              $.prettyPhoto.close();
      	          	  return false;
      	            }); 
                  },
                  markup: '<div class="pp_container" role="dialog"><div class="pp_loaderIcon"></div><div class="pp_placeholder"></div></div><div class="pp_overlay"></div>',
                  height: 340,
                  width: 880
                });
              });
              </script>
          </div>
        </div>
        <div class="control-group">
          <label for="tel" class="control-label">Điện thoại</label>
          <div class="controls">
            <input type=text name=tel id=tel class="input-xxlarge" value="<?php echo set_value('tel', $booth['tel']); ?>">
         	</div>
        </div>
        <div class="control-group">
          <label for="fax" class="control-label">Fax</label>
          <div class="controls">
            <input type=text name=fax id=fax class="input-xxlarge" value="<?php echo set_value('fax', $booth['fax']); ?>">
         	</div>
        </div>
        <div class="control-group">
          <label for="email" class="control-label">Email</label>
          <div class="controls">
            <input type=text name=email id=email class="input-xxlarge" value="<?php echo set_value('email', $booth['email']); ?>">
         	</div>
        </div>
        <div class="control-group">
          <label for="website" class="control-label">Website</label>
          <div class="controls">
            <input type=text name=website id=website class="input-xxlarge" value="<?php echo set_value('website', $booth['website']); ?>">
         	</div>
        </div>
        <div class="control-group">
          <label for="hotline" class="control-label">Hotline</label>
          <div class="controls">
            <input type=text name=hotline id=hotline class="input-xxlarge" value="<?php echo set_value('hotline', $booth['hotline']); ?>">
         	</div>
        </div>
        <div class="control-group">
          <div class=controls>
            <button class="btn btn-primary" type=submit name=booth-submit value="Lưu thay đổi">Lưu thay đổi</button>
          </div>
        </div>
      </form>
      
      <div class="row" style="position: relative;">
        <div style="float: left; width: 364px">
          <div id="banner_small_1_append">
            <?php if ($booth['banner_small_1']): ?>
              <img src="<?php echo base_url('upload/booth/'. $_SESSION['userLoggedIn']['id'] . '/banner_small_1/' . $booth['banner_small_1']); ?>" />
            <?php else: ?>
              <img src="<?php echo base_url('theme/images/sample/booth/468x180.jpg'); ?>" />
            <?php endif; ?>
          </div>
          <form method="post" id="banner_small_1_form" action=<?php echo base_url('booth/ajaxUploadFile/banner_small_1/'.$booth['id']); ?> enctype=multipart/form-data > 
            <div class="file-upload-wrapper">
            	<input class="file-upload" type="file" id="banner_small_1" name="banner_small_1" />Thay đổi banner</div>
            <button type="submit" class="submit_btn">Upload Files</button>
          </form>
        </div>
        <div style="float: right; width: 364px">
          <div id="banner_small_2_append">
            <?php if ($booth['banner_small_2']): ?>
              <img src="<?php echo base_url('upload/booth/'. $_SESSION['userLoggedIn']['id'] . '/banner_small_2/' . $booth['banner_small_2']); ?>" />
            <?php else: ?>
              <img src="<?php echo base_url('theme/images/sample/booth/468x180.jpg'); ?>" />
            <?php endif; ?>
          </div>
          <form method="post" id="banner_small_2_form" action=<?php echo base_url('booth/ajaxUploadFile/banner_small_2/'.$booth['id']); ?> enctype=multipart/form-data > 
            <div class="file-upload-wrapper">
            	<input class="file-upload" type="file" id="banner_small_2" name="banner_small_2" />Thay đổi banner</div>
            <button type="submit" class="submit_btn">Upload Files</button>
          </form>
        </div>
      </div>
      
      <?php if (!empty($booth['id'])): ?>
        <?php $this->load->view('booth/element/ProductCategories.php'); ?>
      <?php endif; ?>
    </div> <!-- /management-block -->
    
    <br />
    
    <h5>Vị trí người đăng gian hàng</h5>
    <hr class="hr" />
    <div class="management-block">
      <script src="<?php echo base_url('theme/js/frontend/google.map.js'); ?>" type="text/javascript"></script>
  	  <script type="text/javascript">
        $(document).ready(function(){
          function OnLoad() {
            // Initialize the map with default UI.
            gMap = new google.maps.Map(document.getElementById("map"), {
              center: new google.maps.LatLng(21.0327, 105.8489),	// Ha Noi
              zoom: 13,
              mapTypeId: 'roadmap'
            });
          
            // Initialize the local searcher
            gLocalSearch = new GlocalSearch();
            gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);
    
            var edit = "<?php echo $booth['lat']; ?>";
            if (edit) {
      		  // Khởi tạo marker khi edit
              marker = new google.maps.Marker({
                position: new google.maps.LatLng(document.getElementById('lat').value, document.getElementById('lng').value),
                map: gMap,
            	  draggable: true
              });
              
              google.maps.event.addListener(marker, 'dragend', function() {
            	  document.getElementById('lat').value = this.get('position').lat();
            	  document.getElementById('lng').value = this.get('position').lng();
              }); 
    
              gMap.setCenter(new google.maps.LatLng(document.getElementById('lat').value, document.getElementById('lng').value));
            }
          }
  
          GSearch.setOnLoadCallback(OnLoad);
        });
      </script>
      <form method="post" class="form-horizontal googlemap-form" action=<?php echo base_url('booth/addMap'); ?>>
        <div class="control-group">
          <label for="record" class="control-label">Bản đồ google</label>
          <div class="controls">
  		  <input type="text" id="queryInput" value="" style="width: 434px;" />
            <input type="button" class="btn btn-primary" value="Go!" onclick="doSearch()"/>
          </div>
        </div>
        <div class="control-group">
          <div class="controls">
  		  <div id="map" style="height: 350px; width: 500px; border: 1px solid #979797;"></div>
         	</div>
        </div>
        <div class="control-group">
          <div class=controls>
  		  <input type="hidden" name=lat id="lat" value="<?php echo set_value('lat', $booth['lat']); ?>"/>
  		  <input type="hidden" name=lng id="lng" value="<?php echo set_value('lng', $booth['lng']); ?>"/>
            <input type=hidden name=id id=id value="<?php echo $booth['id']; ?>"/>
            <button class="btn btn-primary" type="submit" value="Lưu thay đổi">Lưu thay đổi</button>
          </div>
        </div>
      </form>
    </div> <!-- /management-block -->
    
    <footer class="row">
      <?php if ($booth['avatar']): ?>
        <img class="booth-footer-avatar" src="<?php echo base_url('upload/booth/' . $booth['user_id'] . '/avatar/' . $booth['avatar']); ?>" />
      <?php else: ?>
        <img class="booth-footer-avatar" src="<?php echo base_url('theme/images/sample/booth/avatar.jpg'); ?>" />
      <?php endif; ?>

      <div class="booth-info">
        <h1 class="booth-name"><?php echo $booth['name']; ?></h1>
        <?php echo $booth['address']; ?> <br />
        <table>
          <tbody><tr>
            <td><b>Điện thoại:</b> <?php echo $booth['tel']; ?></td>
            <td><b>Fax:</b> <?php echo $booth['fax']; ?></td>
          </tr><tr>
            <td><b>Email:</b> <a href="mailto:dsfg@sdf.com"><?php echo $booth['email']; ?></a></td>
          </tr><tr>
            <td><b>Website:</b> <a href="<?php echo $booth['website']; ?>"><?php echo $booth['website']; ?></a></td>
          </tr></tbody>
        </table>
      </div>
      <div style="border:1px dashed gray;position:absolute;width: 760px;top: 102px"></div>
      
      <div class="social-block">
        <div style="font-size: 16px;font-weight: bold; margin-left: 85px; margin-bottom:14px;">Chia se:</div>
        <a href="javascript:void(0);" data-block="social-icon-1"><i class="social-icon-1"></i></a>
        <a href="javascript:void(0);" data-block="social-icon-2"><i class="social-icon-2"></i></a>
        <a href="javascript:void(0);" data-block="social-icon-3"><i class="social-icon-3"></i></a>
        <a href="javascript:void(0);" data-block="social-icon-4"><i class="social-icon-4"></i></a>
      </div>
      <div class="f-link-info">
        <a href="javascript:void(0);" data-block="policy">Chính sách gian hàng</a>
        <a href="javascript:void(0);" data-block="cooperation">Hợp tác kinh doanh</a>
        <a href="javascript:void(0);" data-block="introduction">Giới thiệu</a>
      </div>
    </footer>
    
    <form method="post" action="<?php echo base_url('booth/add'); ?>">
      <div class="social-form" id="social-icon-1" style="display: none;">
		<input type=text name=social1 id=social1 style="width: 782px; margin-top: 9px;" value="<?php echo set_value('social1', $booth['social1']); ?>" placeholder="http://">
        <button class="btn btn-primary" type="submit" name="social-submit" value="Lưu thay đổi">Lưu thay đổi</button>
      </div>
      <div class="social-form" id="social-icon-2" style="display: none;">
        <input type=text name=social2 id=social2 style="width: 782px; margin-top: 9px;" value="<?php echo set_value('social2', $booth['social2']); ?>" placeholder="http://">
        <button class="btn btn-primary" type="submit" name="social-submit" value="Lưu thay đổi">Lưu thay đổi</button>
      </div>
      <div class="social-form" id="social-icon-3" style="display: none;">
        <input type=text name=social3 id=social3 style="width: 782px; margin-top: 9px;" value="<?php echo set_value('social3', $booth['social3']); ?>" placeholder="http://">
        <button class="btn btn-primary" type="submit" name="social-submit" value="Lưu thay đổi">Lưu thay đổi</button>
      </div>
      <div class="social-form" id="social-icon-4" style="display: none;">
        <input type=text name=social4 id=social4 style="width: 782px; margin-top: 9px;" value="<?php echo set_value('social4', $booth['social4']); ?>" placeholder="http://">
        <button class="btn btn-primary" type="submit" name="social-submit" value="Lưu thay đổi">Lưu thay đổi</button>
      </div>
    </form>
    
    <form method="post" action="<?php echo base_url('booth/add'); ?>">
      <div id="policy">
        <textarea style="height: 120px;width:782px" name="link1" id="link1"><?php echo set_value('link1', $booth['link1']); ?></textarea> 
        <button class="btn btn-primary" type="submit" name="link-submit" value="Lưu thay đổi">Lưu thay đổi</button>
      </div>
      <div id="cooperation">
        <textarea style="height: 120px;width:782px" name="link2" id="link2"><?php echo set_value('link2', $booth['link2']); ?></textarea> 
        <button class="btn btn-primary" type="submit" name="link-submit" value="Lưu thay đổi">Lưu thay đổi</button>
      </div>
      <div id="introduction">
        <textarea style="height: 120px;width:782px" name="link3" id="link3"><?php echo set_value('link3', $booth['link3']); ?></textarea> 
        <button class="btn btn-primary" type="submit" name="link-submit" value="Lưu thay đổi">Lưu thay đổi</button>
      </div>
    </form>
    
  </div> <!-- /management-wrapper -->
</div> <!-- /management-container -->

<script type="text/javascript">
  $(document).ready(function() {

	// Hiển thị form tương ứng để add các thông tin chính sách, hợp tác, giới thiệu cho gian hàng
	$('.f-link-info > a').click(function(){
	  $('#policy').hide();
	  $('#cooperation').hide();
	  $('#introduction').hide();
	  $("#"+$(this).data("block")).show();
	});
	  
	// validate form on keyup and submit
    $(".product-form").validate({
		ignore: "",
	    submitHandler: function(form) {
	      $pnk('description').value = $pnk('epic_iframe_description').contentWindow.document.body.innerHTML;
		  form.submit();
		}
    }); // end validate
	  
	$('.items li a').click(function(){
	  $('.product-block').hide();
	  $("#"+$(this).data("block")).show();
	}); 
	
	$('.social-block a').click(function(){
	  $('.social-form').hide();
	  $("#"+$(this).data("block")).show();
	});
	  
    // Sự kiện click tab bất kỳ
    $('.product-block ul li a').click(function(){ 
      $('.product-block ul li').removeClass('active');
      $(this).parent().addClass('active'); 
     
      var currentTab = $(this).attr('href'); 
      $('.product-block .tabs > div').hide();
      $(currentTab).show();
       
      return false;
    }); // end Sự kiện click tab bất kỳ
    
  });
</script>  
<script src="<?php echo base_url('theme/js/frontend/jquery.Jcrop.min.js'); ?>"></script>
<script src="<?php echo base_url('theme/js/frontend/jquery.json-2.4.min.js'); ?>"></script>
<script src="<?php echo base_url('theme/js/frontend/ajaxFileUpload.js'); ?>"></script>